package cn.bugstack.domain.strategy.model.entity;

import cn.bugstack.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @Title: StrategyEntity
 * @Author lz
 * @Date 2025/7/25 10:53
 * @description: 策略实体对象
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {
    /** 抽奖策略ID */
    private Long strategyId;
    /**策略抽奖模型**/
    private String ruleModels;
    /** 抽奖策略描述 */
    private String strategyDesc;

    public String[] ruleModels(){
        if (StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(Constants.SPLIT);
    }
    public String getRuleWeight(){
        if (StringUtils.isBlank(ruleModels)){//没有ruleModels,不需要进行这一步
            return null;
        }
        String[] ruleModels = this.ruleModels();
        for (String ruleModel : ruleModels){
            if ("rule_weight".equals(ruleModel)) return ruleModel;
        }
        return null;
    }
}
